package com.jm.product.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.common.collect.Lists;
import com.jm.product.controller.dto.Menu;

@Controller
public class IndexController {

	@RequestMapping(value={"","/index"})
	public String Index(){
		return "index";
	}
	
	@RequestMapping("menu")
	@ResponseBody
	public List<Menu> menu(@RequestParam(required=false) String id){
		// 该处数据应从数据库中查询
//		System.out.println(id);
		
		List<Menu> menus = Lists.newArrayList() ;
		
		Menu sys = new Menu("1","系统设置","menu-icon fa fa-cog","");
		Menu code = new Menu("1_1","编码管理","menu-icon fa fa-glass","/index");
		sys.getMenus().add(code);
		menus.add(sys);
		
		Menu product = new Menu("2","商品","menu-icon fa fa-list","");
		Menu product1 = new Menu("2_1","商品管理","menu-icon fa fa-laptop","");
		product.getMenus().add(product1);
		Menu productList = new Menu("2_1_1","商品列表","menu-icon fa fa-list","/product/goods");
		Menu productAdd = new Menu("2_1_2","添加商品","menu-icon fa fa-plus","/product/goods/selectCat");
		product1.getMenus().add(productList);
		product1.getMenus().add(productAdd);
		
		Menu product2 = new Menu("2_2","商品设置","menu-icon fa fa-cogs","");
		product.getMenus().add(product2);
		Menu cat = new Menu("2_2_1","分类管理","menu-icon fa fa-glass","/product/goodsCat/treeTable");
		Menu brand = new Menu("2_2_2","品牌管理","menu-icon fa fa-glass","/product/brand");
		Menu type = new Menu("2_2_3","类型管理","menu-icon fa fa-glass","/product/goodsType");
		Menu spec = new Menu("2_2_4","规格管理","menu-icon fa fa-glass","/product/specification");
		product2.getMenus().add(cat);
		product2.getMenus().add(brand);
		product2.getMenus().add(type);
		product2.getMenus().add(spec);
		menus.add(product);
		
		Menu auth = new Menu("3","权限管理","menu-icon fa fa-user","");
		Menu user = new Menu("3_1","用户管理","menu-icon fa fa-user","/product/brand");
		Menu role = new Menu("3_2","角色管理","menu-icon fa fa-apple","/product/brand");
		Menu menu = new Menu("3_3","菜单管理","menu-icon fa fa-list","/product/brand");
		Menu dept = new Menu("3_4","部门管理","menu-icon fa fa-glass","/product/brand");
		auth.getMenus().add(user);
		auth.getMenus().add(role);
		auth.getMenus().add(menu);
		auth.getMenus().add(dept);
		menus.add(auth);
		
		Menu basic = new Menu("4","基础数据","menu-icon fa fa-leaf","");
		Menu site = new Menu("4_1","站点管理","menu-icon fa fa-glass","/index");
		basic.getMenus().add(site);
		menus.add(basic);
		
		return menus;
	}
}
